package com.atguigu.spring6.resource;

import org.springframework.core.io.FileSystemResource;

import java.io.InputStream;

//
public class FileSystemResouceDemo {
    public static void main(String[] args) {
        // 相路径与绝对路径都可以使用
//        loadFileSystemResource("c:\\atguigu.txt");
        loadFileSystemResource("atguigu.txt");
    }
    public static void loadFileSystemResource(String str) {
        FileSystemResource resouce = new FileSystemResource(str);
        System.out.println(resouce.getFilename());
        try {
            InputStream inputStream = resouce.getInputStream();
            byte[] bytes = new byte[1024];
            while (inputStream.read() != -1) {
                System.out.println(new String(bytes));
            }
        }catch (Exception e) {
            e.printStackTrace();
        }
    }
}
